<template>
	<view class="banklistpage">
		<view class="bank-card" v-if="Bankcards.length==0">
			<view class="img-box">
				<image :src="photo_cdn1+'/zpupload/20230727/2d6cc62889dd0b217c.png'" mode=""></image>
				<view class="text-box">
					<text>您还没有绑定银行卡</text>
					<text>请绑定您本人银行卡或公司账户，以保障资金安全</text>
				</view>
			</view>
			
		</view>
		
		<view class="banklistdata" v-if="Bankcards.length!=0">
			<view class="bank_item"  v-for="(item,index) in Bankcards" :key="index">
				<image class="bankitembg" :src="photo_cdn1+'/zpupload/20230727/bb3943d64c41b29bdd.png'" mode=""></image>
				<view class="card_info">
					<view class="num">
						<view class="card_num">{{item.bank_name}}</view>
						<view class="time">{{item.bank_num}}</view>
					</view>
				</view>
				<view class="disbind" @tap="delBankfun(item)" >解除绑定</view>
			</view>
		</view>
		
		
		<button class="addbankbutton" type="primary"  @tap="addcard">绑定银行卡</button>
	</view>
</template>

<script>
	import {myBank,delBank} from "@/utils/api/user.js";	
	import config from "@/utils/config.js";
	let {staticurl,photo_cdn1} = config.baseUrl;
	export default{
		data(){
			return {
				staticurl,
				photo_cdn1,
				Bankcards:[
					
				],
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.myBankfun();
		},
		methods:{
			//跳转到添加银行卡
			addcard(){
				wx.navigateTo({
					url:'/pages/mine/bind_bank/bind_bank'
				})
			},
			//我的银行卡
			myBankfun(){
				myBank({
					
				}).then((res)=>{
					if(res.code==1){
						this.Bankcards = res.data.Bankcards;
					}else{
						this.Bankcards = [];
					}
				})
			},
			//解绑银行卡
			delBankfun(bankitem){
				this.$showModal({
					title:'提示',
					concent:'你确定要解绑这张卡吗?',
					confirmVal:'确定',
					cancelVal:'取消',
				}).then(res=>{
					delBank({
						bankcard_id:bankitem.id,
					}).then((res)=>{
						if(res.code==1){
							this.$api.msg("删除成功");
							this.myBankfun();
						}else{
							this.$api.msg(res.msg);
						}
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	@import "./banklist.scss";
</style>